package com.hxk.exception;

import java.io.FileNotFoundException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
/**
 * 全局异常类使用实现HandlerExceptionResolver接口实现
 * @author Cactus
 */
@Configuration
public class GlobalException3 implements HandlerExceptionResolver{

	@Override
	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
		ModelAndView  mav = new ModelAndView();
		mav.addObject("error", ex.toString());
		if(ex instanceof FileNotFoundException) {
			mav.setViewName("error5");
		}
		if(ex instanceof CloneNotSupportedException) {
			mav.setViewName("error6");
		}
		return mav;
	}
}
